﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Home.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="WebHoiChoMuaBan.Controllers.Helpers" %>
<%@ Import Namespace="WebHoiChoMuaBan.Controllers.Utility" %>
<%@ Import Namespace="WebHoiChoMuaBan.Models" %>

<asp:Content ID="Content2" ContentPlaceHolderID="TitleHolder" runat="server">
    Nhà đất
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadHolder" runat="server">
<script type="text/javascript">
    $(document).ready(function () {
        var right = $('#nbright').height();
        var left = $('#nbleft').height();
        if (left > right)
            $('#nbright').height(left);
        else
            $('#nbleft').height(right + 3);

    });
</script>
   <script>
       $(document).ready(function () {
           var triggers = $(".modalInput").overlay({

               // some mask tweaks suitable for modal dialogs
               mask: {
                   color: '#ebecff',
                   loadSpeed: 200,
                   opacity: 0.9
               },

               closeOnClick: false
           });

           var buttons = $("#yesno button").click(function (e) {

               // get user input
               var yes = buttons.index(this) === 0;

               // do something with the answer
               triggers.eq(0).html("You clicked " + (yes ? "yes" : "no"));
           });

           $("#prompt form").submit(function (e) {

               // close the overlay
               triggers.eq(1).overlay().close();

               // get user input
               var input = $("input", this).val();

               // do something with the answer
               triggers.eq(1).html(input);

               // do not submit the form
               return e.preventDefault();
           });
       });
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ListMenuHeader" runat="server">
  <!-- Group list menu -->
  <div id="nbleft" style="float:left;width:194px;background-color:#EEF2F5;border: 1px solid #d8dfea;">
  <img src='../Content/Images/hoi_bg_listmenu_nhadat.png' height="150px" width="150px" style="margin:8px 8px 8px 20px" />
  </div>
  <div id="nbright"  style="float:right;width:80%">
        <div class="hoicho_group_product">
            <div class="hoicho_header_feature">
                <ul>
                <%
                    string bold = "style='font-weight: bold'";
                    PageType curPage = (PageType)ViewData["CurrentPage"];
                    Category curCate = (Category)ViewData["CurrentCategory"];
                    int needSell   = (int)ViewData["NeedSell"];
                    int provinceId = (int)ViewData["ProvinceId"];
                    
                    List<Category> cate = (List<Category>)ViewData["Categories"];
                    int i;
                    foreach(Category c in cate)
                    {
                        bool isCurrent = curCate != null && 
                                            ((curCate.ParentCategory != null && c.CateId == curCate.ParentCategory.CateId) || 
                                             c.CateId == curCate.CateId);
                        Response.Write(string.Format("<li class='{0}'><a href='{1}?pid={2}&cid={3}&p={4}&need={5}&prvid={6}'>{7}</a></li>", 
                                                    (isCurrent ? "selected_menu" : string.Empty), 
                                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                    curPage.PageId,
                                                    c.CateId,
                                                    1,
                                                    needSell,
                                                    provinceId,
                                                    c.CateName));
                    }
                 %>
                </ul>
            </div>
            <div class="hoicho_feature_content">
                <div class="private_breakpage_replycoment col_left reset_margin">
                <%
                    Response.Write(string.Format("<a {0} href='{2}?pid={3}&cid={4}&p={5}&need={6}&prvid={8}'>Cần bán</a> | <a {1} href='{2}?pid={3}&cid={4}&p={5}&need={7}&prvid={8}'>Cần mua</a>",
                                                    (needSell == NewsProductHelper.NEED_SELL ? bold : string.Empty),
                                                    (needSell == NewsProductHelper.NEED_BUY ? bold : string.Empty),
                                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                    curPage.PageId,
                                                    (curCate != null ? curCate.CateId : 0),
                                                    1,
                                                    NewsProductHelper.NEED_SELL,
                                                    NewsProductHelper.NEED_BUY,
                                                    provinceId));
                %>
                </div>
                <div class="hoicho_select_province col_right">
                    <span class="hoicho_margin_right">
                        <%
                            StringBuilder provLinks = new StringBuilder();
                            provLinks.Append("<a {0} href='{4}?pid={5}&cid={6}&p={7}&need={8}&prvid=2'>Hà Nội</a> | ");
                            provLinks.Append("<a {1} href='{4}?pid={5}&cid={6}&p={7}&need={8}&prvid=6'>Hải Phòng</a> | ");
                            provLinks.Append("<a {2} href='{4}?pid={5}&cid={6}&p={7}&need={8}&prvid=3'>Hồ Chí Minh</a> | ");
                            provLinks.Append("<a {3} href='{4}?pid={5}&cid={6}&p={7}&need={8}&prvid=5'>Đà Nẵng</a> |");
                            Response.Write(string.Format(provLinks.ToString(),
                                                    (provinceId == 2 ? bold : string.Empty), // {0}
                                                    (provinceId == 6 ? bold : string.Empty), // {1}
                                                    (provinceId == 3 ? bold : string.Empty), // {2}
                                                    (provinceId == 5 ? bold : string.Empty), // {3}
                                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                    curPage.PageId,
                                                    (curCate != null ? curCate.CateId : 0),
                                                    1,
                                                    needSell // buy or sell
                                                    ));
                         %>
                    </span>
                    <span>
                                <%
                            string selected = "class='highlight'";
                        %>
                        <button class="modalInput buttonpro" rel="#prompt">
                            Tỉnh Khác</button>
                        <script type="text/javascript">
                            $("a[title]").tooltip();
                        </script>
                        <%--</select>--%>
                        <div class="modalpro" id="prompt">
                            <button type="button" class="close" style="float:right;border:none;cursor:pointer">
                                Đóng
                            </button>
                            <br />
                            <table>
                                <tr>
                                    <%
                                        List<Province> provinces = (List<Province>)ViewData["Provinces"];
                                        int k = 0;
                                        
                                        foreach (Province pr in provinces)
                                        {
                                            //Response.Write(string.Format("<option value='{0}' {2}>{1}</option>", 
                                            //                            pr.ProvId, 
                                            //                            pr.ProvName,
                                            //                            (provinceId == pr.ProvId ? selected : string.Empty)
                                            //                            ));
                                    %>
                                    <td>
                                        <%Response.Write(string.Format("<a {7} href='{0}?pid={1}&cid={2}&p={3}&need={4}&prvid={5}'>{6}</a>", Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }), curPage.PageId, (curCate != null ? curCate.CateId : 0), 1, needSell, pr.ProvId, pr.ProvName,pr.ProvHighlight==1? selected:String.Empty)); %>
                                    </td>
                                    <%
k++;
if (k % 3 == 0)
{
                                    %>
                                </tr>
                                <tr>
                                    <%
}
                                    %>
                                    <%
}
                                    %>
                                </tr>
                            </table>
                        </div>
                        <%--   <script type="text/javascript">
                            jQuery("#cbbProvince").change(function () {
                                location.href=<%=string.Format("'{0}?pid={1}&cid={2}&p={3}&need={4}'",
                                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                    curPage.PageId,
                                                    (curCate != null ? curCate.CateId : 0),
                                                    1,
                                                    needSell // buy or sell
                                                    ) %> + '&prvid=' + jQuery(this).val();
                            });
                        </script>--%>
                    </span>
                </div>
            </div>
            
                <%
                    //int j = 1;
                    //foreach (Category c in cate)
                    {
                        //Response.Write(string.Format("<div id='cate_{1}' class='hoicho_group_listmenu_fation page_{2}' {0}>", (j>1 ? "style='display:none'" : string.Empty), c.CateId, c.PageId));
                        Response.Write("<div>");
                        //j++;
                        
                        if (curCate != null)
                        {
                            List<CategoryHelper.SubCategory> subcategories = null;
                            if (curCate.SubCategories != null && curCate.SubCategories.Count > 0)
                            {
                                //Số dòng mỗi cột
                                subcategories = (from sub in curCate.SubCategories
                                                 select new CategoryHelper.SubCategory
                                                 {
                                                     id = sub.CateId,
                                                     name = sub.CateName
                                                 }).ToList();
                            }
                            else if (curCate.ParentCategory != null)
                            {
                                subcategories = (from sub in curCate.ParentCategory.SubCategories
                                                 select new CategoryHelper.SubCategory
                                                 {
                                                     id = sub.CateId,
                                                     name = sub.CateName
                                                 }).ToList();
                            }

                            if (subcategories != null)
                            {
                                int perRow = (int)Math.Ceiling((double)subcategories.Count / 4);

                                //4 cột subcategories
                                for (i = 0; i < 4; i++)
                                {
                                    var subCate = (from sub in subcategories select sub).Skip(perRow * i).Take(perRow);
                                    if (subCate != null)
                                    {
                                        Response.Write("<div class='private_menu_list_product'><ul>");
                                        foreach (var s in subCate)
                                            Response.Write(string.Format("<li><img src='../Content/Images/arrow_listproduct.gif'/><a href='{0}?pid={1}&cid={2}&p={3}' style='font-weight: {4}'>{5}</a></li>",
                                                                            Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                                            curPage.PageId,
                                                                            s.id,
                                                                            1,
                                                                            ((curCate != null && curCate.CateId == s.id) ? "bold" : "normal"),
                                                                            s.name));
                                        Response.Write("</ul></div>");
                                    }
                                }
                            }
                        }
                        Response.Write("</div>");
                    }
                 %>
        </div>
        </div>
        <div class="clr"></div>
        <!-- End Group list menu -->
</asp:Content>
<%--end List Menu Header--%>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentHolder" runat="server">
        <!-- Group list menu -->
        <%--
        <div class="hoicho_group_product">
            <div class="hoicho_header_feature">
                <ul>
                    <li class="selected_menu"><a class="selected_menu" href="#">Nhà đất</a></li>
                </ul>
                <div class="private_write_right private_margin_topright">
                    <div class="private_button_upload">
                        <a href="#">
                            <img src="/../Content/Images/icon_plus_up.gif">
                            Tìm chi tiết hơn</a>
                    </div>
                </div>
            </div>
            <div class="hoicho_feature_content">
                <div class="private_breakpage_replycoment col_left reset_margin">
                    <a class="selected_menu" href="#">Cần mua</a> | <a href="#">Cần bán</a> | <a href="#">
                        Cần thuê</a> | <a href="#">Cho thuê</a> | <a href="#">Dự án mới</a>
                </div>
                <div class="hoicho_select_province col_right">
                    <span class="hoicho_margin_right"><a href="#">Hà nội</a> | <a href="#">Hải phòng</a>
                        | <a href="#">Hồ chí minh</a> | <a href="#">Đà nẵng</a> | </span><span>
                            <select class="hoicho_input_select_province" id="">
                                <option>Tỉnh khác</option>
                            </select></span>
                </div>
            </div>
            <div class="hoicho_select_money">
                <span>Chọn giá tiền:</span>
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    500 triệu</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    1 tỷ</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    2 tỷ</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    3 tỷ</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    500 triệu</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    1 tỷ</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    2 tỷ</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    3 tỷ</label>&nbsp;&nbsp;
            </div>
            <div class="hoicho_group_listmenu_property">
                <p class="hoicho_text_list">
                    Chung cư [1035] Cao ốc văn phòng [178] Căn hộ cao cấp [2634] Nhà mặt tiền [1835]
                    Villa, Biệt thự [793] Nhà hẻm [642] Đất nền [1224] Đất thổ cư [642] Đất dự án [948]
                    Mặt bằng [78] Phòng trọ [32] Nhà hàng, Khách sạn [64] Khác [44] Nhà xưởng, nhà kho
                    [139] Đất quy hoạch [20] Đất vườn [54] Ðất nông nghiệp [135] Nhà phố [653] Nhà thô
                    [4] Đất công nghiệp [1]
                </p>
            </div>
        </div> --%>
        <!-- End Group list menu -->
        <!-- Group list menu -->
   <%--     <div class="hoicho_group_product">
            <div class="hoicho_header_feature">
                <ul>
                <%
                    PageType curPage = (PageType)ViewData["CurrentPage"];
                    Category curCate = (Category)ViewData["CurrentCategory"];
                    
                    List<Category> cate = (List<Category>)ViewData["Categories"];
                    int i;
                    foreach(Category c in cate)
                    {
                        bool isCurrent = curCate != null && 
                                            ((curCate.ParentCategory != null && c.CateId == curCate.ParentCategory.CateId) || 
                                             c.CateId == curCate.CateId);
                        //Response.Write(string.Format("<li class='page_{3} {0}'><a href='#' onclicked='switchTab({3}, this); return false;' rel='cate_{2}' >{1}</a></li>", ((curCate != null && c.CateId == curCate.ParentCategory.CateId) || (curCate == null && i == 1) ? "selected_menu" : string.Empty), c.CateName, c.CateId, c.PageId));
                        Response.Write(string.Format("<li class='{0}'><a href='{1}?pid={2}&cid={3}&p={4}'>{5}</a></li>", 
                                                    (isCurrent ? "selected_menu" : string.Empty), 
                                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                    curPage.PageId,
                                                    c.CateId,
                                                    1,
                                                    c.CateName));
                    }
                 %>
                </ul>
            </div>
            <div class="hoicho_feature_content">
                <div class="private_breakpage_replycoment col_left reset_margin">
                    <a href="#" class="selected_menu">Cần mua</a> | <a href="#">Cần bán</a>
                     | <a href="#">Cho thuê</a> | <a href="#">Dự án mới</a>
                </div>
                <div class="hoicho_select_province col_right">
                    <span class="hoicho_margin_right">
                        <a href="#">Hà nội</a> | 
                        <a href="#">Hải phòng</a> | 
                        <a href="#">Hồ chí minh</a> | 
                        <a href="#">Đà nẵng</a> | 
                    </span>
                    <span>
                        <select id="Select1" class="hoicho_input_select_province">
                            <option>Tỉnh khác</option>
                        </select>
                    </span>
                </div>
            </div>
            <div class="hoicho_select_money">
                <span>Chọn giá tiền:</span>
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    500 triệu</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    1 tỷ</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    2 tỷ</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    3 tỷ</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    500 triệu</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    1 tỷ</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    2 tỷ</label>&nbsp;&nbsp;
                <input type="radio" value="radio" id="radio" name="radio">
                <label for="radio">
                    3 tỷ</label>&nbsp;&nbsp;
            </div>
                <%
                    //int j = 1;
                    //foreach (Category c in cate)
                    {
                        //Response.Write(string.Format("<div id='cate_{1}' class='hoicho_group_listmenu_fation page_{2}' {0}>", (j>1 ? "style='display:none'" : string.Empty), c.CateId, c.PageId));
                        Response.Write("<div>");
                        //j++;
                        
                        if (curCate != null)
                        {
                            List<CategoryHelper.SubCategory> subcategories = null;
                            if (curCate.SubCategories != null && curCate.SubCategories.Count > 0)
                            {
                                //Số dòng mỗi cột
                                subcategories = (from sub in curCate.SubCategories
                                                 select new CategoryHelper.SubCategory
                                                 {
                                                     id = sub.CateId,
                                                     name = sub.CateName
                                                 }).ToList();
                            }
                            else
                            {
                                subcategories = (from sub in curCate.ParentCategory.SubCategories
                                                 select new CategoryHelper.SubCategory
                                                 {
                                                     id = sub.CateId,
                                                     name = sub.CateName
                                                 }).ToList();
                            }
                            int perRow = (int)Math.Ceiling((double)subcategories.Count / 4);

                            //4 cột subcategories
                            for (i = 0; i < 4; i++)
                            {
                                var subCate = (from sub in subcategories select sub).Skip(perRow * i).Take(perRow);
                                if (subCate != null)
                                {
                                    Response.Write("<div class='private_menu_list_product'><ul>");
                                    foreach (var s in subCate)
                                        Response.Write(string.Format("<li><a href='{0}?pid={1}&cid={2}&p={3}' style='font-weight: {4}'>{5}</a></li>",
                                                                        Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                                        curPage.PageId,
                                                                        s.id,
                                                                        1,
                                                                        ((curCate != null && curCate.CateId == s.id) ? "bold" : "normal"),
                                                                        s.name));
                                    Response.Write("</ul></div>");
                                }
                            }
                        }
                        Response.Write("</div>");
                    }
                 %>
        </div>--%>
        <!-- End Group list menu -->

       <%-- <div class="hoicho_topbanner reset_margin">
            <img alt="" src="http://static.news.zing.vn/zing/ZingBanner/960x120_200711.gif" width="731" />
        </div>--%>
        <!-- Group san pam noi bat -->
     <div style="float:right" id="toggle">Thu Lại</div>
        <div class="clr"></div>
     <div class="hoicho_group_product" >
        <div class="hoicho_top_groupproduct">
            <p class="hoicho_texttop_product">
                Sản phẩm nổi bật</p>
        </div>
        <div class="hoicho_group_product_content" id="sanphamnoibat">
            <%
                NewsProductHelper.FetchProductResult lstHot = (NewsProductHelper.FetchProductResult)ViewData["HotProducts"];
                int i = 1;
                foreach (var hot in lstHot.products)
                {
                    if (i++ != 5)
                        Response.Write("<div class='hoicho_product_thumb'>");
                    else
                        Response.Write("<div class='hoicho_product_thumb reset_margin'>");
            %>
            <!-- Product thumb -->
            <center>
            <% 
                        
                string link = string.Format("<a href='{0}?prid={1}'>",
                                    Url.Action("Detail", "NewsProduct", new { productTitle = MiscUtil.EscapeString(hot.NProTitle) }),
                                    hot.NProId
                                    );
            %>
            <%=link %>
            
            <img src="/../Content/Images/Upload/<%=(hot.NewsProductThumbs != null && hot.NewsProductThumbs.Count > 0 ? hot.NewsProductThumbs.First().NProThumbName : "" )%>"
                width="94" height="80" alt="" class="hoicho_img_productthumb" />
            </a>
            </center>
            <%-- <p class="font_bold" >--%>
            <%
                if (hot.NProTitle.Length > 40)
                {
                    Response.Write(string.Format("<p class='font_bold' title='{0}' >", hot.NProTitle));
                }
                else
                {
                   // Response.Write("<div style='height:36px !important'>");
                    Response.Write("<p class='font_bold' style='height:36px !important'>");
                }
            %>
            <%=link %>
            <%//Minh Thêm
/*-----------Truncate Product Title----------------*/
/*Thiết lập Title = 40 chars*/
if (hot.NProTitle.Length > 40)
{
    hot.NProTitle = hot.NProTitle.Substring(0, 37) + "...";
}
else
{
    int iCount = 40 - hot.NProTitle.Length;
    for (int k = 0; k < iCount; k++)
    {
        hot.NProTitle += " ";
    }
}
/*-----------End truncate Product Title*/ %>
            <%=hot.NProTitle %>
            </p>
           <%-- </div>--%>
             </a>
            <br />
            <p>
                <%
//Minh Thêm
/*-----------Truncate Product Provice Name----------------*/
/*Thiết lập Product Provice Name = 10 chars*/
//if (hot.Province.ProvName.Length > 10)
//{
//    hot.Province.ProvName = hot.Province.ProvName.Substring(0, 7) + "...";
//}
/*-----------End truncate Product Provice Name*/ %>
                Nơi rao:
                <%--<span class="hoicho_ograne_color">--%>
                <%if (hot.Province.ProvName.Length > 10)
                  {
                      Response.Write(String.Format("<span class='hoicho_ograne_color' title='{0}'>", hot.Province.ProvName));
                      hot.Province.ProvName = hot.Province.ProvName.Substring(0, 7) + "...";
                  }
                  else
                  {
                      Response.Write("<span class='hoicho_ograne_color'>");
                  } %>
                <%=hot.Province.ProvName%>
                <%Response.Write("</span"); %></p>
            <p>
                Ngày đăng: <span class="hoicho_ograne_color">
                    <%=hot.NProDate.ToString("dd/MM/yyyy") %></span></p>
            <div class="hoicho_bt_product_price">
                <%=(hot.NProPrice == null ? "Thương lượng" : hot.NProPrice.Value + " " + hot.NProPriceUnit) %></div>
            <p>
                <img src="/../Content/Images/hoicho_icon_view.gif" alt="" /><span class="hoicho_margin_leftright">Lượt
                    xem:</span><span class="hoicho_margin_leftright hoicho_ograne_color"><%=hot.NProViewCount %></span></p>
            <p>
                <img src="/../Content/Images/hoicho_icon_savenews.gif" alt="" class="hoicho_margin_leftright" /><a
                    href="#" class="SaveButton" onclick="SaveNews(<%=hot.NProId %>)" data-url='<%=hot.NProId %>'>Lưu tin</a></p>
            <%
Response.Write("</div>");
                }
            %>
            <!-- End Product thumb -->
  
        </div>
        <script type="text/javascript">
            $(".hoicho_group_product_content p[title]").tooltip();
            $(".hoicho_group_product_content span[title]").tooltip();
        </script>
    </div>
        <!-- End Group san pam noi bat -->
        <!-- End Group san pam noi bat -->
        <a name="noibat"></a>
          <!-- Group san pham moi -->
        <div class="hoicho_group_product">
            <table width="100%" border="0">
                <tr>
                    <td colspan="2" class="hoicho_top_groupproduct">
                        <p class="hoicho_texttop_product">
                            Sản phẩm mới</p>
                    </td>
                    <td width="15%" align="left" bgcolor="#F5F7FB" class="hoicho_border_bottom">
                        <strong>Tỉnh/T.Phố</strong>
                    </td>
                    <td width="12%" align="right" bgcolor="#F5F7FB" class="hoicho_border_bottom" style="padding-right:20px">
                        <strong>Xem</strong>
                    </td>
                    <td width="4%" align="center" bgcolor="#F5F7FB" class="hoicho_border_bottom">
                        <strong>Ảnh</strong>
                    </td>
                </tr>
                <%
                    NewsProductHelper.FetchProductResult lstNew = (NewsProductHelper.FetchProductResult)ViewData["NewProducts"];
                    i = 0;
                    foreach (NewsProduct n in lstNew.products)
                    {
                        if (i % 2 == 0)
                            Response.Write("<tr bgcolor='#fafafa'>");
                        else
                            Response.Write("<tr bgcolor='#e0f0ff'>");
                        i++;
                        
                        string link = string.Format("<a href='{0}?prid={1}'>",
                                            Url.Action("Detail", "NewsProduct", new { productTitle = MiscUtil.EscapeString(n.NProTitle) }),
                                            n.NProId                                            
                                            );
                     %>
                    <td valign="top" >
                        <%=link %>
                            <img src="/../Content/Images/hoicho_arrow_newproduct.gif" alt="" />
                        </a>
                    </td>
                    <td valign="top">
                        <%=link %>
                            <%=n.NProTitle %></a>
                    </td>
                    <td valign="top">
                        <%=string.Format("<a href='{0}'>{1}</a>", n.Province.ProvId, n.Province.ProvName) %>
                        
                    </td valign="top">
                    <td align="right"  style="padding-right:20px">
                        <%=n.NProViewCount %>
                    </td>
                    <td valign="top">
                        <img src="/../Content/Images/Upload/<%=(n.NewsProductThumbs != null && n.NewsProductThumbs.Count > 0 ? n.NewsProductThumbs.First().NProThumbName : "" )%>" alt="" width="24" height="22" />
                    </td>
                <%
                        Response.Write("</tr>");
                    }
                         %>
            </table>
        </div>
    
        <!-- End Group san pham moi -->
        <div class="private_breakpage" style="text-align: right">
            <%
PageType curPage = (PageType)ViewData["CurrentPage"];
Category curCate = (Category)ViewData["CurrentCategory"];
NewsProductHelper.FetchProductResult lstNews = (NewsProductHelper.FetchProductResult)ViewData["NewProducts"];
int p;
if (Request.QueryString["p"] != null && int.TryParse(Request.QueryString["p"], out p))
{
                 %>
            <% if (p > 1)
               { %><a href='<%=string.Format("{0}?pid={1}&cid={2}&p={3}#noibat'",
                                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                    curPage.PageId,
                                                    Request.QueryString["cid"],
                                                    p-1) %>'><img src="/../Content/Images/arrow_breakpage_left.gif" alt="">&nbsp;Trang trước</a> <% } %>
            <%
if (p > 3)
    Response.Write(string.Format("<a href='{0}?pid={1}&cid={2}&p={3}#noibat' {4}>{5}</a> ",
                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                    curPage.PageId,
                                    Request.QueryString["cid"],
                                    1,
                                    string.Empty,
                                     1));
if (p > 4)
    Response.Write("...");
int total = lstNews.totalPages;
int from = (p - 2 < 1 ? 1 : p - 2);
int to = (p + 2 >= total ? total : p + 2);
for (i = from; i <= to; i++)
    Response.Write(string.Format("<a href='{0}?pid={1}&cid={2}&p={3}#noibat' {4}>{5}</a> ",
                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                    curPage.PageId,
                                    Request.QueryString["cid"],
                                    i,
                                    (i == p ? "class='menu_select'" : string.Empty),
                                     i));
if (p <= total - 4)
    Response.Write("...");
if (p <= total - 3)
    Response.Write(string.Format("<a href='{0}?pid={1}&cid={2}&p={3}#noibat' {4}>{5}</a> ",
                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                    curPage.PageId,
                                    Request.QueryString["cid"],
                                    total,
                                    string.Empty,
                                    total));
             %>
            
            <% if (p < lstNews.totalPages)
               { %><a href='<%=string.Format("{0}?pid={1}&cid={2}&p={3}#noibat'",
                                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                    curPage.PageId,
                                                    Request.QueryString["cid"],
                                                    p+1) %>'>Trang sau&nbsp;<img src="/../Content/Images/arrow_breakpage_right.gif" alt=""></a> <% } %>
            <% }
               %>
        </div>
        <!-- Chi tiet san pham -->
        <div class="hoicho_group_product reset_border bg_reset">
            <%
                i = 0;
                foreach (NewsProduct n in lstNews.products)
                {
                 %>            
            <!-- THUMB LIST ND -->
            <div class="hoicho_thumb_news">
                <div class="hoicho_thumb_newsleft">                
                    <%--<a href="<%=Url.Action("RealEstate_Detail", "News") %>" class="hoicho_img_thumbnews">--%>
                    <% string link = string.Format("<a href='{0}?prid={1}' class='hoicho_img_thumbnews'>",
                                            Url.Action("Detail", "NewsProduct", new { productTitle = MiscUtil.EscapeString(n.NProTitle) }),
                                            n.NProId                                            
                                            );
                    %>
                    <%=link %>
                        <img src="/../Content/Images/Upload/<%=(n.NewsProductThumbs != null && n.NewsProductThumbs.Count > 0 ? n.NewsProductThumbs.First().NProThumbName : "" )%>" /></a>
                    <p>
                        <%=link %>
                            <%=n.NProTitle %></a>
                        <img src="/../Content/Images/VIP-1.gif" alt="vip.gif">
                    </p>
                    <p>
                        <span class="hoicho_time_update"><%=n.NProDate %></span>
                        <br>
                        <%=n.NProIntro%>
                        <br>
                        <% if (n.RealEstateAttribute != null) { %>
                        <span class="hoicho_label_news">DTSD:</span><%=n.RealEstateAttribute.RAttrUsableArea%>m<sup>2</sup>.
                        <% } %>
                    </p>
                    <p>
                    </p>
                </div>
                <div class="hoicho_thumb_newscode">
                    <p class="hoicho_codenews">
                        Mã số tin: <strong><%=n.NProId %></strong></p>
                    <ul>
                        <li><a href="#">VND</a></li>
                        <li><a href="#">SJC</a></li>
                        <li><a href="#">USD</a></li>
                    </ul>
                    <div class="clear">
                    </div>
                    <p>
                        <strong><%=(n.NProPrice == null ? "Thương lượng" : n.NProPrice.Value + " " + n.NProPriceUnit) %></strong></p>
                    <p class="hoicho_icon_vote">
                        <img alt="" src="/../Content/Images/icon_home.jpg">&nbsp;&nbsp;|&nbsp;&nbsp;
                        <img alt="" src="/../Content/Images/icon_start.jpg">&nbsp;&nbsp;&nbsp; <span class="hoicho_savenews">
                            <a href="#" onclick="SaveNews(<%=n.NProId %>)">Lưu tin</a></span>
                    </p>
                </div>
            </div>
            <!-- End THUMB LIST ND -->
            <%
                }
             %>
        </div>
        <div class="private_breakpage" style="text-align: right">
            <%
                lstNews = (NewsProductHelper.FetchProductResult)ViewData["NewProducts"];
                if (Request.QueryString["p"] != null && int.TryParse(Request.QueryString["p"], out p))
                {
                 %>
            <% if (p > 1) { %><a href='<%=string.Format("{0}?pid={1}&cid={2}&p={3}#noibat'",
                                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                    curPage.PageId,
                                                    Request.QueryString["cid"],
                                                    p-1) %>'><img src="/../Content/Images/arrow_breakpage_left.gif" alt="">&nbsp;Trang trước</a> <% } %>
            <%
                if (p > 3)
                    Response.Write(string.Format("<a href='{0}?pid={1}&cid={2}&p={3}#noibat' {4}>{5}</a> ",
                                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                    curPage.PageId,
                                                    Request.QueryString["cid"],
                                                    1,
                                                    string.Empty,
                                                     1));
                if (p > 4)
                    Response.Write("...");
                int total = lstNews.totalPages;
                int from = (p - 2 < 1 ? 1 : p - 2);
                int to = (p + 2 >= total ? total : p + 2);
                for (i = from; i <= to; i++)
                    Response.Write(string.Format("<a href='{0}?pid={1}&cid={2}&p={3}#noibat' {4}>{5}</a> ",
                                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                    curPage.PageId,
                                                    Request.QueryString["cid"],
                                                    i, 
                                                    (i==p ? "class='menu_select'" : string.Empty),
                                                     i));
                if (p <= total - 4)
                    Response.Write("...");
                if (p <= total - 3)
                    Response.Write(string.Format("<a href='{0}?pid={1}&cid={2}&p={3}#noibat' {4}>{5}</a> ",
                                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                    curPage.PageId,
                                                    Request.QueryString["cid"],
                                                    total,
                                                    string.Empty,
                                                    total));
             %>
            
            <% if (p < lstNews.totalPages) { %><a href='<%=string.Format("{0}?pid={1}&cid={2}&p={3}#noibat'",
                                                    Url.Action("Page", "Home", new { pageName = MiscUtil.EscapeString(curPage.PageName) }),
                                                    curPage.PageId,
                                                    Request.QueryString["cid"],
                                                    p+1) %>'>Trang sau&nbsp;<img src="/../Content/Images/arrow_breakpage_right.gif" alt=""></a> <% } %>
            <% }  %>
        </div>
</asp:Content>
